const path = require('path');
const HtmlWebpackPlugin=require("html-webpack-plugin");
module.exports = {
    entry: './src/js/index.js',
    output: {
        path: path.resolve(__dirname, 'public'),
        filename: 'js/bundle-[hash].js',
        
    },
    "mode":"development",
    devServer:{
        contentBase:"./public",
        //本地服务路径
        inline:true
        ///实时刷新
    },
    module:{
        rules:[
            {
                test:/\.css$/,
                use:['style-loader','css-loader']
            },
            {
                test:/\.(jpg|png|webp)$/,
                loader:'file-loader',
                options:{
                    esModule:false
                }
            },
            {
                test:/\.html$/,
                use:'html-withimg-loader',
            },
            {
                test:/\.(woff|ttf|svg|eot|xttf|woff2)$/,
                use:'file-loader?limit=1024&name=./fonts/[name].[ext]'
            },

        ]
    },
    plugins:[
        new HtmlWebpackPlugin({
            template:"./src/index.html",
            // filename:"a.html",
            minify:{
                removeAttributeQuotes:true,//去除多余引号
                removeComments:true,//去除注释
                removeEmptyAttributes:true,//去除空属性
                collapseWhitespace:true//去除空格
            }
        })
    ]
    
  };